<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
  <meta name="baidu-site-verification" content="code-UjJKh3jtOo">
  <link rel="stylesheet" href="//unpkg.com/@highlightjs/cdn-assets@11.5.0/styles/atom-one-dark.min.css">
  <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
  <title>Tit1e</title>
  <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-2767111597631391" crossorigin="anonymous"></script>
  
<link rel="stylesheet" href="/css/style.css">

<meta name="generator" content="Hexo 6.3.0"><link rel="alternate" href="/atom.xml" title="Tit1e" type="application/atom+xml">
</head>

<body class="dark">
    <div class="container">
    <header class="header">
  <div class="title">
      <a href="/" class="logo">Tit1e</a>
      <div class="btn-dark"></div>
      <script>
        let bodyClx = document.body.classList;
        let btnDark = document.querySelector('.btn-dark');
        let sysDark = window.matchMedia('(prefers-color-scheme: dark)');
        let darkVal = localStorage.getItem('dark');

        let setDark = (isDark) => {
        bodyClx[isDark ? 'add' : 'remove']('dark');
        localStorage.setItem('dark', isDark ? 'yes' : 'no');
        };

        setDark(darkVal ? darkVal === 'yes' : sysDark.matches);
        requestAnimationFrame(() => bodyClx.remove('not-ready'));

        btnDark.addEventListener('click', () => setDark(!bodyClx.contains('dark')));
        sysDark.addEventListener('change', (event) => setDark(event.matches));
      </script>
  </div>
    <ul class="menu">
        
        
        
        
        <li class="menu-item ">
            <a href="/" class="menu-item-link">Home</a>
        </li>
        
        
        <li class="menu-item ">
            <a href="/archives/" class="menu-item-link">Archives</a>
        </li>
        
        
        <li class="menu-item ">
            <a href="/atom.xml" class="menu-item-link">RSS</a>
        </li>
        
        
        <li class="menu-item ">
            <a target="_blank" rel="noopener" href="https://pixeltimer.art" class="menu-item-link">Pixel Timer</a>
        </li>
        
    </ul>
    <div class="search-box">
        <input type="search" id="search" placeholder="搜索">
    </div>
</header>
    <article class="post">
  <div class="post-meta">
    <span class="post-time">5 / 23, 2020</span>
  </div>
  <div class="post-title">
    <h1 class="title">批量删除微博，可自定义删除内容</h1>
  </div>
  
  <ul class="post-tags">
    
    <li class="tag-item">
      #折腾
    </li>
    
  </ul>
  
  <div class="post-content">
    <p>首先浏览器上登录微博，浏览器要求： QQ浏览器，360极速浏览器，谷歌浏览器，火狐浏览器等都行，可以先试试，不行再换。Safari我记得默认是关闭调试模式的，</p>
<p>Windows 用户直接按 F12 打开控制台，或者在网页上右键，会有【元素审查】、【检查】类似这种的菜单项，打开它，正常情况浏览器内会出现一个窗口。</p>
<p>然后点击【console】标签页，复制代码，在箭头在的位置粘贴代码，如果你要按条件删除，那就先编辑好条件，然后按回车。</p>
<p><img src="https://personal-1251959693.cos.ap-chengdu.myqcloud.com/2020-05-23-082341.png"></p>
<p>根据实际使用来说，删除要等个十来秒才会执行，当页面在闪的时候说明在删除了。</p>
<p>使用的时候自动跳到下一页好像有点问题。如果页面长时间没反应，那就刷新一下页面，再粘贴执行一遍代码。</p>
<p>这是按条件删除微博的代码：</p>
<pre><code class="js">&#39;use strict&#39;;
var s = document.createElement(&#39;script&#39;)
s.setAttribute(
  &#39;src&#39;,
  &#39;https://lib.sinaapp.com/js/jquery/2.0.3/jquery-2.0.3.min.js&#39;
)
s.onload = function() &#123;
  let index = 0
  setInterval(function() &#123;
    if (!$(&#39;div[action-type=&quot;feed_list_item&quot;]&#39;).length) &#123;
      // 删完符合条件的微博，翻到下一页
      $(&#39;a.next&#39;).click()
    &#125; else &#123;
      const firstItem = $(&#39;div[action-type=&quot;feed_list_item&quot;]&#39;)[index]
      const text = $(firstItem).find(&#39;.WB_feed_detail .WB_detail div[node-type=&quot;feed_list_content&quot;]&#39;).text()
      // 删除微博正文中含有 “今天” 两个字的微博
      const needDelete = text.indexOf(&#39;今天&#39;) &gt; 0
      // 如果要匹配多个：
      // 下面这样写会把微博正文中含有 “今天” 或者 “第一” 的微博删除，含有其中之一就会被删
      // const needDelete = text.indexOf(&#39;今天&#39;) &gt; 0 || text.indexOf(&#39;第一&#39;) &gt; 0

      // 这样写是将微博正文中含有 “今天” 和 “第一” 的微博删除，必须两个都包含才会被删
      // const needDelete = text.indexOf(&#39;今天&#39;) &gt; 0 &amp;&amp; text.indexOf(&#39;第一&#39;) &gt; 0

      if(needDelete)&#123;
        $(firstItem).find(&#39;a[action-type=&quot;feed_list_delete&quot;]&#39;)[0].click()
        $(firstItem).find(&#39;a[action-type=&quot;ok&quot;]&#39;)[0].click()
      &#125;else&#123;
        index += 1
      &#125;
    &#125;

    // 滚动到底部自动加载
    $(&#39;html, body&#39;).animate(&#123; scrollTop: $(document).height() &#125;, &#39;slow&#39;)
  &#125;, 800)
&#125;
document.head.appendChild(s)
</code></pre>
<p>这是删除所有微博的代码：<a target="_blank" rel="noopener" href="https://greasyfork.org/en/scripts/14709-weibored-js/code">来源</a></p>
<pre><code class="js">&#39;use strict&#39;;

var s = document.createElement(&#39;script&#39;);
s.setAttribute(
  &#39;src&#39;,
  &#39;https://lib.sinaapp.com/js/jquery/2.0.3/jquery-2.0.3.min.js&#39;
);
s.onload = function() &#123;
  setInterval(function() &#123;
    if (!$(&#39;a[action-type=&quot;feed_list_delete&quot;]&#39;)) &#123;
      $(&#39;a.next&#39;).click();
    &#125; else &#123;
      $(&#39;a[action-type=&quot;feed_list_delete&quot;]&#39;)[0].click();
      $(&#39;a[action-type=&quot;ok&quot;]&#39;)[0].click();
    &#125;

    // scroll bottom let auto load
    $(&#39;html, body&#39;).animate(&#123; scrollTop: $(document).height() &#125;, &#39;slow&#39;);
  &#125;, 800);
&#125;;
document.head.appendChild(s);
</code></pre>

  </div>
  <div class="post-near">
    
    <a
      class="post-near-prev"
      href="/p/a0cde071.html"
      title="vue 监听子组件生命周期"
    >
      <span class="arrow">←</span>
      <span class="post-near-title">
        vue 监听子组件生命周期
      </span>
    </a>
    
    
    <a
      class="post-near-next"
      href="/p/9623f65.html"
      title="uni-app 小程序给所有页面添加分享"
    >
      <span class="post-near-title">
        uni-app 小程序给所有页面添加分享
      </span>
      <span class="arrow">→</span>
    </a>
    
  </div>
</article>

    <footer class="footer">
  <p>本博客采用 <a class="license-link" rel="license noopener" target="_blank" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">署名-非商业性使用-相同方式共享 4.0 国际</a>协议进行许可</p>
  <p>
    <span>Thanks For <a target="_blank" rel="noopener" href="https://github.com/nanxiaobei/hugo-paper" taget="_blank">hugo-paper</a></span>
    <span style="margin-left: 10px;">&copy; 2016-2025 by Tit1e</span>
  </p>
</footer>
    </div>
    <script src="//unpkg.com/@highlightjs/cdn-assets@11.5.0/highlight.min.js"></script>
<script>
  hljs.initHighlightingOnLoad();
  var _hmt = _hmt || [];
    (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?6349d3bc54baea0b04a65145c5e3b799";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
    })();
    const block = document.querySelectorAll('.post-content')[0]
    block.addEventListener('click', e => {
        const {nodeName, src} = e.target
        if(nodeName !== 'IMG') return
        document.body.classList.add('overflow-hidden')
        const div = document.createElement('div')
        div.id = 'global-cover'
        div.title = '点击关闭'
        const a = document.createElement('a')
        a.href = src
        a.target="_blank"
        a.title = '点击打开原图'
        const img = document.createElement('img')
        img.className = 'show-pic'
        img.src = src
        a.appendChild(img)
        div.appendChild(a)
        document.body.appendChild(div)
    })
    document.body.addEventListener('click', e => {
        if(e.target.id === 'global-cover'){
            document.body.classList.remove('overflow-hidden')
            document.body.removeChild(e.target)
        }
    })
</script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-7M04VN3JZ4"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-7M04VN3JZ4');
</script>

<script src="/js/search.js"></script>


</body>
</html>